<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="JavaScript" src="images/js/jquery.min.js"></script>
<script type="text/javascript" src="images/js/dialog.js"></script>
<link href="images/js/dialog_simp.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body,td,th {
	font-family: 宋体;
	font-size: 12px;
}
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.righttable{ margin-top:20px;}
.r13b{ color:#FF0000}
-->
</style><div id="righttable" class="righttable">
   <form action="{$PHPCMS['siteurl']}top.php?action=top" method="post" name="myform">
          <table width="{$width}" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#cccccc" style="border-collapse: collapse" >
		        <tr>
                <td align="right"><span class="r13b">超级优惠:</span></td>
                <td>每天置顶的费用为<span class="r13b">{$todayprice}</span>元</td>
              </tr>
              <tr>
                <td align="right">置顶天数:</td>
                <td>
				<label><input name="toptime" type="radio" onclick="info_top_select(this)" value="1" checked="checked"/>
				1天</label>
				<label><input type="radio" name="toptime" value="2" onclick="info_top_select(this)"/>2天</label>
				<label><input type="radio" name="toptime" value="3" onclick="info_top_select(this)"/>3天</label>
				<label><input type="radio" name="toptime" value="7" onclick="info_top_select(this)"/>7天</label>
				<label><input type="radio" name="toptime" value="30" onclick="info_top_select(this)"/>30天</label>
                </td>
              </tr>
              <tr>
                <td align="right">&nbsp;</td>
                <td><p>此次置顶需要花费您<span class="r13b" id="need_point">0</span>元。您现在拥有<span class="r13b" id="point">{$_amount}</span>元，<span class="red" id="need_recharge"></span></p></td>
              </tr>
			  <tr>
                <td align="right">&nbsp;</td>
                <td><input	type="submit" name="dosubmit" id="dosubmit" class="dialog" value="确认置顶">
</td>
			  </tr>
     </table>
		  <input type="hidden" value="{$id}" name="id"/>
		  <input type="hidden" value="" name="price" id="price" />
  </form>
</div>
<script type="text/javascript"> 
$(function(){
	info_top_select(this);
})

function need_recharge() {
	var need_point = $('#need_point').html();
	var point = $('#point').html();
	var need_recharge = Number(point)-Number(need_point);
	//alert(need_recharge);
	if(need_recharge < 0) {
		$("#need_recharge").html('<a href="{$PHPCMS['siteurl']}pay/showpayment.php?action=type&pay=online&amount='+Math.abs(need_recharge)+'" target="_blank">余额不足,马上充值'+Math.abs(need_recharge)+'元</a>');
		$('#dosubmit').attr('disabled',"true").val('余额不足，无法置顶');
	} else {
		$("#need_recharge").html('');
		$('#dosubmit').attr('disabled','').val('提交本次推荐置顶');
	}
}
function info_top_select(obj) {
	var toptime = $("input[name='toptime']:checked").attr('value');

	var chk = $("input[name='toptype[]'][type='checkbox']");
	var count = chk.length;
	var data = need_nifen = '';
	var top_data = new Array(); 
	for (var i=0; i < count; i++) {
		if(chk.eq(i).attr("checked")==true) {
			top_data += chk.eq(i).val()+'_';
		}
	}


	var select_top_type = top_data.length;
	$.post("{$PHPCMS['siteurl']}top.php?action=toptime", { toptype: top_data, toptime: toptime },
		function(data){
			$("#need_point").html(data);
			$("#price").val(data);
			need_recharge();
		}
	);
}
</script>